<template>
	<view >
		<!-- <js-lang title="home.title" :showBtn="true"></js-lang> -->
		<u-swiper :height="300" :list="imgList" :title="false" @click="imgListClick"></u-swiper>
		 <view class="content" style="flex-direction: column;">
		 	<view style="width: 100%;background: #fff;border-radius: 10px;">
		 		<view style="padding: 10px 0 0 20px;font-weight: bold;">
		 			任务信息
		 		</view>
		 		<view class="Grid">
		 			<view class="Grid-Item" v-for="item in List2" :key="item.id" @click="jump(item.url)">
						
		 				<view class="GSimg">
							<!-- <u-badge :count="todoCount"></u-badge> -->
							<u-badge :count="todoCount" v-if="item.id == 1"></u-badge>
		 					<image class="Image" :src="item.img"></image>
		 					<view class="GStitle">{{ item.title }}</view>
		 				</view>
		 
		 			</view>
		 		</view>
		 	</view>
		 </view>
		 
		 <view class="content" style="flex-direction: column;">
		 	<view style="width: 100%;background: #fff;border-radius: 10px;">
		 		<view style="padding: 10px 0 0 20px;font-weight: bold;">
		 			维护信息
		 		</view>
		 		<view class="Grid">
		 			<view class="Grid-Item" v-for="item in menuList1" :key="item.code" @click="jump(item.url)">
		 				<view class="GSimg">
		 					<image class="Image" :src="item.src"></image>
		 					<view class="GStitle">{{ item.menuName }}</view>
		 				</view>
		 
		 			</view>
		 		</view>
		 	</view>
		 </view>
		<!-- <custom-tab-bar ref="customtab1" :current-index="currentIndex" @changeTab="handleTabChange" v-if="customTabBar"/> -->
	</view>
</template>

<script>
	import config from "@/common/config";
	import customTabBar from '@/pages/asd/components/customTabBar.vue';
	import checkVersion from "@/pages/lq-upgrade/checkVersion.js";
	import { mapState } from "vuex";
	export default {
		// @click="navTo('/pages/bpm/myTaskTodo')"
		components: {customTabBar },
		data() {
			return {
				List2: [{
						id: 1,
						img: '/static/jeesite/img/rw.png',
						url: '/pages/bpm/myTaskTodo',
						title: '待办任务'
					},
					{
						id: 999,
						img: '/static/jeesite/img/yb.png',
						url: '/pages/bpm/myTaskHistory',
						title: '已办任务'
					},
					{
						id: 9999,
						img: '/static/jeesite/img/qb.png',
						url: '/pages/bpm/myRuntime',
						title: '全部任务'
					},
				],
				List3: [
					{
					  code: "2",
					  isSHow: false,
					  src: "/static/image/scan.png",
					  subTitle:'使用',
					  menuName: "使用登记",
					  url: "/pages/asd/use/add",
					},{
					  code: "4",
					  isSHow: false,
					  src: "/static/image/sbsy.png",
					  subTitle:'使用',
					  menuName: "使用经历",
					  url: "/pages/asd/use/list",
					},{
					  code: "1",
					  // code: config.TASK_BUS_TYPE_CGRK,
					  isSHow: false,
					  src: "/static/image/sbwx.png",
					  subTitle:'维修',
					  menuName: "维修经历",
					  url: "/pages/asd/repair/list",
					},
					{
					  code: "3",
					  isSHow: false,
					  src: "/static/image/sbby.png",
					  subTitle:'保养',
					  menuName: "保养经历",
					  url: "/pages/asd/upkeep/list",
					},
					{
					  code: "5",
					  isSHow: false,
					  src: "/static/image/muju.png",
					  subTitle:'工装',
					  menuName: "工装信息",
					  url: "/pages/asd/mold/add",
					},
					{
					  code: "6",
					  isSHow: false,
					  src: "/static/image/muju.png",
					  subTitle:'工装',
					  menuName: "工装查询",
					  url: "/pages/asd/mold/moldSearchList",
					},
				],
				stringPermissions: [],
				imgList: [
					{image: '/static/jeesite/banner/1.jpg'},
					{image: '/static/jeesite/banner/3.jpg'},
				],
				todoCount: 0,
				menuList1: [],
				menuList: [],
				customTabBar:true,
				currentIndex:0,
			}
		},
		onShow() {
			this.refreshCount();
		},
		created() {
			 
		},
		onLoad() {
			this.upgrade();
			var _this = this;
			this.$u.api.menuTree().then(res => {
				
				if (res.length > 0) {
					res.forEach(item => {
						if ('APP管理' == item.menuName) {
							item.childList.forEach(item2 => {
								if ('APP模具菜单' == item2.menuName) {
									this.showMenu(item2.childList);
								}
							})

						}
					})

				}
			});
			// this.$u.api.authInfo().then(res => {
			// 	this.stringPermissions=(res==null || res.stringPermissions==null)?[]:res.stringPermissions;
			// });
		},
		methods: {
			refreshCount() {
				// 获取待办个数
				this.$u.api.bpm.myTaskList({status:1,pageSize:1}).then(res => {
					this.todoCount = res.count || 0;
				});
			},
			handleTabChange(pagePath) {
				// 切换页面逻辑，可使用uni.navigateTo等API
				uni.reLaunch({ url: pagePath });
			},
			//检查版本更新
			upgrade() {
			  // #ifdef APP-PLUS
			  this.$u.api.upgradeCheck().then((res) => {
			    console.log(res, "res");
			    let url = res.data.apkUrl
			      ? res.data.apkUrl
			      : this.vuex_config.xtUrl + res.data.xtUrl;
			    if (res.result == "true") {
			      checkVersion({
			        name: res.data.upTitle, //最新版本名称
			        code: res.data.upVersion, //最新版本号
			        content: `${res.data.upContent}`, //更新内容
			        url, //下载链接
			        forceUpdate: true, //是否强制升级
			      });
			    }
			  });
			  // #endif
			},
			jump(url) {
				uni.navigateTo({
					url,
				})
			},
			
			//显示菜单
			showMenu(list) {
				this.menuList1 = list
				this.List3.forEach(item => {
					this.menuList1.forEach(res => {
						console.log('req,item',item.src)
						if(res.menuName == item.menuName){
							res.src = item.src;
							res.url = item.url;
						}
						
						// res.childList.forEach(req => {
							
						// 	// if (req.extend?.extendS2 == item.extend?.extendS2 ) {
						// 	// 	req.menuIcon = item.menuIcon;
						// 	// 	req.url = item.url;
						// 	// }
						// })

					})
				})

				console.log(this.menuList1, 'this.menuList1===');
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			imgListClick(index) {
				console.log(`点击了第${index + 1}页图片`)
			},
			itemClick(index) {
				console.log(index);
			}
		}
	}
</script>

<style lang="scss">
	.Grid-Item{
		position: relative;
	}
	page {
		background-color: #f8f8f8;
	}
	.content {
		/* text-align: center; */
		padding: 10px;
		// background-color: #eee;
		height: 100%;
		display: flex;
		flex-direction: column;
	}

	.bottom {
		color: #000000;
	}

	.line {
		width: 1000px;
		height: 1.5px;
		background-color: #e5e5e5;
	}

	.wrap {
		padding: 24rpx;
	}

	.u-row {
		margin: 40rpx 0;
	}

	.demo-layout {
		height: 80rpx;
		border-radius: 8rpx;
	}

	.bg-purple {
		background: #d3dce6;
	}

	.bg-purple-light {
		background: #e5e9f2;
	}

	.bg-purple-dark {
		background: #99a9bf;
	}

	.Grid {
		width: 100%;
		float: left;
		overflow: hidden;
		display: flex;
		flex-wrap: wrap;
		// justify-content: space-between;
		align-content: space-between;
		// background: #f7f7f7;
		// padding: 10rpx 0;
		// background: url('/static/image/userBg.png');
		// background-size: cover;
		// background-position: bottom;

		.Grid-Item {
			width: 25%;
			height: 213rpx;
			text-align: center;
			// border:1rpx solid #ccc;
			box-sizing: border-box;

			.GSimg {
				width: 96rpx;
				height: 96rpx;
				margin-top: 42rpx;
				margin-left: 50rpx;

				.Image {
					width: 60rpx;
					height: 60rpx;
				}
			}

			.GStitle {
				width: 100%;
				height: 34rpx;
				line-height: 30rpx;
				color: #06121e;
				font-size: 24rpx;
				margin-top: 18rpx;
			}
		}
	}
</style>